package atguigu.pUtils;

public class Evm {

    private Double bac;
    private Double ac;
    private Double pv;
    private Double ev;
    private Double cv;
    private Double sv;
    private Double cpi;
    private Double spi;
    private Double etc;
    private Double eac;
    private Double tcpi;
    private Double vac;

    private int t = 0;// 0:典型,1:非典型,2:摆烂

    public Double getBac() {
        return bac;
    }

    public void setBac(Double bac) {
        this.bac = bac;
    }

    public Double getAc() {
        return ac;
    }

    public void setAc(Double ac) {
        this.ac = ac;
    }

    public Double getPv() {
        return pv;
    }

    public void setPv(Double pv) {
        this.pv = pv;
    }

    public Double getEv() {
        return ev;
    }

    public void setEv(Double ev) {
        this.ev = ev;
    }

    public Double getCv() {
        return cv;
    }

    public void setCv(Double cv) {
        this.cv = cv;
    }

    public Double getSv() {
        return sv;
    }

    public void setSv(Double sv) {
        this.sv = sv;
    }

    public Double getCpi() {
        return cpi;
    }

    public void setCpi(Double cpi) {
        this.cpi = cpi;
    }

    public Double getSpi() {
        return spi;
    }

    public void setSpi(Double spi) {
        this.spi = spi;
    }

    public Double getEtc() {
        return etc;
    }

    public void setEtc(Double etc) {
        this.etc = etc;
    }

    public Double getEac() {
        return eac;
    }

    public void setEac(Double eac) {
        this.eac = eac;
    }

    public Double getTcpi() {
        return tcpi;
    }

    public void setTcpi(Double tcpi) {
        this.tcpi = tcpi;
    }

    public Double getVac() {
        return vac;
    }

    public void setVac(Double vac) {
        this.vac = vac;
    }

    public int getT() {
        return t;
    }

    public void setT(int t) {
        this.t = t;
    }

    public void jisuanEvm() {
        if (ev != null && ev > 0.0
                && pv != null && pv > 0.0
                && ac != null && ac > 0.0) {
            sv = ev - pv;
            cv = ev - ac;
            cpi = ev / ac;
            spi = ev / pv;
            if (bac != null && bac > 0.0) {
                if (t == 0) {
                    etc = (bac - ev) / cpi;
                } else if (t == 1) {
                    etc = bac - ev;
                } else if (t == 2) {
                    etc = (bac - ev) / (cpi * spi);
                }
                eac = ac + etc;
                vac = bac - eac;
                if (eac - ac > 0.0) {
                    tcpi = (bac - ev) / (eac - ac);
                } else {
                    tcpi = 0.0;
                }
            }
        }
    }

    public static void main(String[] args) {
        Evm e = new Evm();
        e.setBac(2025.00);
        e.setAc(1800.00);
        e.setPv(900.00);
        e.setEv(1012.5);


        e.jisuanEvm();

        System.out.println("CV:" + e.getCv());
        System.out.println("CPI:" + e.getCpi());
        System.out.println("SV:" + e.getSv());
        System.out.println("SPI:" + e.getSpi());

        // 典型偏差
        e.setT(0);
        // 非典型偏差
//        e.setT(1);
        // 摆烂
//        e.setT(2);

        System.out.println("ETC:" + e.getEtc());
        System.out.println("EAC:" + e.getEac());
        System.out.println("TCPI:" + e.getTcpi());
        System.out.println("VAC:" + e.getVac());

    }
}
